package org.lanqiao.tjut.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lanqiao.tjut.bean.StuBean;
import org.lanqiao.tjut.myUtils.MyUtils;
import org.lanqiao.tjut.service.ServiceFactory;

public class stuTestServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		MyUtils.logger_console.debug("准备查询你的成绩");
		// 接收客户端数据请求时进行编码设置，防止中文乱码
		// req.setCharacterEncoding("UTF-8"); //已经使用filter进行了编码设置

		// 使用request的getParameter方法获取前台页面的表单数据
		// 用户名
		String strStuName = req.getParameter("txtStuName");
		MyUtils.logger_console.debug("要查询的名字：" + strStuName);
		

		StuBean stuB = (StuBean) MyUtils.getNewInstance(StuBean.class);
		stuB.setSTUNAME(strStuName);
		String strJumpPage = "";
		// // 将表单数据填充到实体对象属性中
		// UsersBean usersB = (UsersBean)
		// MyUtils.getNewInstance(UsersBean.class);
		// usersB.setUsername(strUserName);

		// 登录验证
		List<StuBean> lstUsers = ServiceFactory.getGradeManagerServiceInstance().doQueryByParas(stuB);

		// 将需要显示的结果集放入session缓存中
		req.getSession().setAttribute("lstUsers", lstUsers);
		// 查询结果页
		strJumpPage = "logined/UserInfoManager/myGrade.jsp";

		req.getRequestDispatcher(strJumpPage).forward(req, resp);
	}

}
